package vnc.diagnostics;

public class Stopwatch {
	
	long lastMil;
	
	public Stopwatch() {
		start();
	}
	
	public void start()
	{
		lastMil = System.currentTimeMillis();
	}
	
	public long stop()
	{
		return System.currentTimeMillis() - lastMil;
	}
	
	public long restart()
	{
		long elapsed = stop();
		start();
		return elapsed;
	}
	
	public void log(String eventName, long elapsed)
	{
		System.out.println(eventName + " took " + elapsed + "ms");
	}
	
	public void logrestart(String eventName)
	{
		log(eventName, restart());
	}
	
}
